#include "DatabaseManager.h"

DatabaseManager Database; 
DatabaseManager::DatabaseManager(){

    cout<<"DatabaseManager::DatabaseManager"<<endl;
    //this->dbPath=dbPath; 
    this->db=SQLite3Singleton::getInstance("homeS.db");
      
}
ReturnStatus DatabaseManager::connect(){
    
    ReturnStatus status;
    try
    {
        /* code */
        if (db ->connect()==SUCCESS)
        {
            /* code */
            status=SUCCESS;
        }else{
            status=FAILURE;

        }
        
    }
    catch(const exception& e)
    {
        cerr << e.what() << '\n';
        status=FAILURE;
    }
    
    
    
    return status;
}
void DatabaseManager::disconnect(){
    try
    {
        db->disconnect();
        
    }
    catch(const exception& e)
    {
        cerr << e.what() << '\n';
    }
    

}
ReturnStatus DatabaseManager::executeQuery(const string& query){

    ReturnStatus status;
    try
    {
        /* code */
        if (db->executeQuery(query)==SUCCESS)   
        {
                /* code */
                status=SUCCESS;
        }else{
            status=FAILURE;

        }

        
    }
    catch(const std::exception& e)
    {
        std::cerr << e.what() << '\n';
        status=FAILURE;
    }
    disconnect();
    return status;
}
vector<string> DatabaseManager::fetchResults(const string& query,const TableChoice tableChoice){

    try
    {
        /* code */
        return db->fetchResults(query,TABLEUSER);
        
    }
    catch(const std::exception& e)
    {
        std::cerr << e.what() << '\n';
        return vector<string>();
    }
    
}
   
    


